<?php 
include('includes/mysqli_connect.php'); 
include('includes/function.php');
 
if($pid= validate_id($_GET["pid"])){
    // New Pid hop le thi truy van csdl 
    $set=get_page_by_id($pid);
    $posts =array();
    if(mysqli_num_rows($set)>0)
       {      
       $pages = mysqli_fetch_array($set,MYSQLI_ASSOC);
       $title=$pages['page_name'];
       $posts[] = array('page_name' =>$pages['page_name'],
                       'content'   =>$pages['content'],
                       'author'    =>$pages['name'],
                       'aid'    =>$pages['user_id'],
                       'post-on'   =>$pages['date']
        );   
        } else {
        echo "<p>There are no post in this category</p>";
        }                        
    }
        else
        {
            // Neu pid khong hop le . thi chuyen huong nguoi dung 
            redirect_to();
        }

include('includes/header.php'); 
include('includes/slide-a.php'); ?>
    <div id="content">   
     <?php
     foreach($posts as $post){
     echo "<div class='post'>
     <h2>{$post['page_name']}</h2>
     <p>".the_content($post['content'])."</p>
     <p class='meta'><strong>Posted by : </strong> <a href='author.php?aid={$post['aid']}'>{$post['author']}</a> | <strong>On :</strong> {$post['post-on']}</p>                                                                                       
     </div>";}
     ?>
    
    
    
    </div><!--end content-->
<?php include('includes/slide-b.php'); 
include('includes/footer.php'); ?>
    
    